/**
 * Represents a nullable value.
 */
enum Option[T] {
    Some(value: T);
    None;

    public function isSome(): Bool {
        match this {
            None => return false;
            default => return true;
        }
    }
    public function isNone(): Bool {
        match this {
            None => return true;
            default => return false;
        }
    }

    public function unwrap(): T {
        match this {
            Some(value) => return value;
            default => panic("unwrap: unexpected missing value");
        }
    }

    public function or(other: T): T {
        match this {
            Some(v) => return v;
            default => return other;
        }
    }

    rules {
        ($this ?? $other) => $this.or($other);

        // ($this ?. $id) => if $this.isSome() then Some($this.unwrap().$id) else None;
    }
}
